import allure
from selenium.webdriver.common.by import By

from base.base1 import Base


class register(Base):
    @allure.step('1、输入用户名')
    def __input_username(self, username):
        self.element_send_keys((By.CSS_SELECTOR, '#username'), username)

    @allure.step('3、输入密码')
    def __input_password(self, password):
        self.element_send_keys((By.CSS_SELECTOR, '#password'), password)
    #填写验证码
    @allure.step('2、输入验证码')
    def __input_code(self, code):
        self.element_send_keys((By.CSS_SELECTOR, '#reg_form2 > div > div > div > div:nth-child(2) > div.liner > input'), code)

    # password2
    @allure.step('4、输入确认密码')
    def __input_password2(self, password2):
        self.element_send_keys((By.CSS_SELECTOR, '#password2'), password2)

    # reg_form2 > div > div > div > div:nth-child(5) > div > input
    @allure.step('5、输入邀请码')
    def __input_invite_number(self, invite_number):
        self.element_send_keys((By.CSS_SELECTOR, '#reg_form2 > div > div > div > div:nth-child(5) > div > input'), invite_number)

    @allure.step('6、点击注册按钮')
    def __login_button(self):
        self.element_click((By.CSS_SELECTOR, '#reg_form2 > div > div > div > div.line.liney.clearfix > div > a'))
    def  get_error_message(self):
        return self.get_text((By.CSS_SELECTOR,'div.layui-layer-content.layui-layer-padding'))
    def register(self, username,code, password,password2, invite_number):
        self.__input_username(username)
        self.__input_password(password)
        self.__input_password2(password2)
        self.__input_code(code)
        self.__input_invite_number(invite_number)
        self.__login_button()